package com.xxx.blog.controller;

import com.github.pagehelper.PageInfo;
import com.xxx.base.utils.R;
import com.xxx.blog.domain.Article;
import com.xxx.blog.domain.Param;
import com.xxx.blog.query.ArticleQuery;
import com.xxx.blog.service.IArticleService;
import com.xxx.blog.service.IParamService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;

/**
 * @author BoWei Wang
 * @date 2025/8/5
 */

@RestController
@RequestMapping("/param")
@Api(tags = "系统参数接口")
public class ParamController {
    @Autowired
    private IParamService paramService;

    @GetMapping
    @ApiOperation("获取参数map")
    public R<Map<String,String>> paramMap() {
        List<Param> all = paramService.findAll();
        
//        HashMap<String, String> map = new HashMap<>();
//        for (Param param : all) {
//            map.put(param.getParam_key(), param.getParam_value());
//        }
        Map<String, String> map = all.stream().collect(Collectors.toMap(Param::getParamKey, Param::getParamValue));

        return R.ok(map);
    }

    

}
